package main

import (
	// "os"
	// "fmt"
	// "log"
	"qianji/service/db"
	"github.com/gorilla/websocket"
	"net/http"
)
// 定义升级器，将 HTTP 请求升级为 WebSocket 连接
var upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}
func handler(w http.ResponseWriter, r *http.Request) {
	// 升级 HTTP 请求为 WebSocket 连接
	conn, err := upgrader.Upgrade(w, r, nil)
	if err != nil {
		log.Println("WebSocket Upgrade Error:", err)
		return
	}
	defer conn.Close()
}
func main() {
	// 定义 WebSocket 路由
	http.HandleFunc("/ws", handler)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		log.Fatal("ListenAndServe Error:", err)
	}
	// utils.GlobalObject.Load("conf/gate.json")
	// db.Init()
	// go app.MasterClient(proto.ServerTypeGate)
	// app.SetShutDownFunc(ShutDown)
	// addr := fmt.Sprintf("%s:%d", utils.GlobalObject.AppConfig.Host, utils.GlobalObject.AppConfig.TcpPort)
	http.HandleFunc("/", wsHandler)
	http.ListenAndServe(addr, nil)
}
